<template>
<Card>
     <p slot="title">
            <Icon type="ios-list-box-outline" />
            系统日志
    </p>

    <Table :data="dataAll" :columns="table2ColumnList" border></Table>
     <div style="margin: 10px;overflow: hidden">
        <div style="float: right;">
            <Page :total="totals" :current="pageData.page" @on-change="changePage"></Page>
        </div>
    </div>
</Card>
</template>
<script>
export default {
  data() {
    return {
      dataAll: [],
      totals: 0,
      tableColumns2: [],
      table2ColumnList: [
        {
          title: "",
          type: "index",
          width: 60,
          align: "center"
        },
        {
          title: "操作人",
          key: "UserName",
          // fixed: "left",
          width: 100
          // render: (h, params) => {
          //   const fav = this.tableData2[params.index].fav;
          //   const style =
          //     fav === 0
          //       ? {
          //           cursor: "pointer"
          //         }
          //       : {
          //           cursor: "pointer",
          //           color: "#f50"
          //         };

          //   return h("div", [
          //     h("Icon", {
          //       style: style,
          //       props: {
          //         type: fav === 0 ? "ios-star-outline" : "ios-star"
          //       },
          //       nativeOn: {
          //         click: () => {
          //           this.toggleFav(params.index);
          //         }
          //       }
          //     }),
          //     h("span", " " + params.row.name)
          //   ]);
          // }
        },
        {
          title: "类型",
          key: "Type",
          // width: 150,
          sortable: true,
          render: (h, { row, cloumn, index }) => {
            return h("span", {}, row["Type"] == 1 ? "系统日志" : "业务日志");
          }
        },
        {
          title: "日志内容",
          key: "Contect",
          minWidth: 300,
          sortable: true
        },
        {
          title: "操作IP",
          key: "Ip",
          // width: 150,
          sortable: true
        },
        {
          title: "状态",
          key: "Status",
          // width: 150,
          sortable: true
        },
        {
          title: "地址",
          key: "Address",
          // width: 150,
          sortable: true
        },
        {
          title: "操作时间",
          key: "Ctime",
          render: (h, {row}) => {
            return h("span",{},moment(row.Ctime).format("YYYY-MM-DD"))
          }
        }
      ],
      pageData: {
        pagesize: 10,
        page: 1,
        searchKey: "",
        flag: 1
      }
    };
  },
  methods: {
    changePage(params) {
      // console.log(params)
      this.pageData.page = params
      // console.log(this.pageData)
      this.getAll();
    },

    getAll() {
      this.$api.getLog(this.pageData).then(res => {
        // console.log(res);
        this.dataAll = res.jdata.data;
        this.totals = res.jdata.total;
      });
    }
  },
  mounted() {
    this.getAll();
  }
};
</script>